package src.week5.SHIYAN2;
import java.util.*;
public class calculate {
    public static void main(String[] args) {
        Scanner scan =new Scanner(System.in);
        float a,b;
        String m,n;
        do{
            System.out.print("PLEASE INPUT a AND b: ");
            a=scan.nextFloat();
            b=scan.nextFloat();
            System.out.print("ENTER THE OPERATION(+ or - or * or / or %):");
            m=scan.next();
            switch(m.charAt(0)){
                case '+':
                    System.out.println("a+b="+add(a,b));
                    break;
                case '-':
                    System.out.println("a-b="+sub(a,b));
                    break;
                case '*':
                    System.out.println("a*b="+mul(a,b));
                    break;
                case '/':
                    System.out.println("a/b="+div(a,b));
                    break;
                case '%':
                    System.out.println("a%b="+mod(a,b));
                    break;
            }
            System.out.println("DO YOU WANT TO CONTINUE?(Y/y or N/n)");
            n=scan.next();
        }while(n.equalsIgnoreCase("y"));
    }
    public static float add(float a,float b){return a+b;}
    public static float sub(float a,float b){return a-b;}
    public static float mul(float a,float b){return a*b;}
    public static float div(float a,float b){return a/b;}
    public static int mod(float a,float b)
    {
        Scanner m=new Scanner(System.in);
        float num1,num2;
        int c,d;
        do{
            num1=a-(int)a;
            num2=b-(int)b;
            if(num1!=0||num2!=0)
            {System.out.println("Please input int type numbers to complete the % operation");
                System.out.print("Please input a and b:");
                a=m.nextFloat();
                b=m.nextFloat();}
        }while((a-(int)a)!=0||(b-(int)b!=0));
        c=(int)a;
        d=(int)b;
        return c%d;
    }
}
